//
//  LOLMyheroCell.m
//  LOLXXbox
//
//  Created by mac on 16/1/30.
//  Copyright © 2016年 Grasstrio. All rights reserved.
//

#import "LOLMyheroCell.h"
#import <Masonry.h>
#import <UIImageView+WebCache.h>
@implementation LOLMyheroCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _heroimage = [[UIImageView alloc] initWithFrame:CGRectZero];
        _heroName = [[UILabel alloc] initWithFrame:CGRectZero];
        _heroName.font = [UIFont systemFontOfSize:16];
        _heroConut = [[UILabel alloc] initWithFrame:CGRectZero];
        _heroConut.textColor = [UIColor blueColor];
        _heroConut.font = [UIFont systemFontOfSize:16];
        _smallName = [[UILabel alloc] initWithFrame:CGRectZero];
        _smallName.font = [UIFont systemFontOfSize:14];
        _smallName.textColor = [UIColor grayColor];
        [self.contentView addSubview:_heroimage];
        [self.contentView addSubview:_heroName];
        [self.contentView addSubview:_heroConut];
        [self.contentView addSubview:_smallName];
    }
    return self;
}


- (void)layoutSubviews {
    [super layoutSubviews];
    [_heroimage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.left.equalTo(self.contentView).offset(10);
        make.bottom.equalTo(self.contentView).offset(-10);
    }];
   
    
    [_heroName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.heroimage.mas_right).offset(10);
        make.top.equalTo(self.contentView).offset(15);
    }];
    

    [_smallName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.heroName.mas_right).offset(10);
        make.top.equalTo(self.contentView).offset(15);
    }];

    [_heroConut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.heroimage.mas_right).offset(10);
        make.top.equalTo(self.heroName).offset(25);
    }];
    
   
}

- (void)setModel:(LOLMyheroModel *)model {
    _model = model;
    _headimage = [NSString stringWithFormat:@"http://img.lolbox.duowan.com/champions/%@_120x120.jpg",_model.enName];
    [_heroimage sd_setImageWithURL:[NSURL URLWithString:_headimage]];
    _heroName.text = _model.title;
    _smallName.text = _model.cnName;
    if ([_model.presentTimes isEqualToString:@""]) {
        _heroConut.text = @"";
    }else {
          _heroConut.text = [NSString stringWithFormat:@"场次：%@",_model.presentTimes];
    }
    

}


@end
